package com.stox.client.http;

import java.util.List;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;

import com.stox.client.ExchangeClient;
import com.stox.dto.Exchange;
import com.stox.dto.web.Response;

@Component
public class ExchangeHttpClient extends AbstractHttpClient implements
		ExchangeClient {

	@Override
	@Cacheable("com.stox.dto.Exchange")
	public List<Exchange> findByCountryCode(Long countryId) {
		return extract(getRestTemplate().exchange(getRootUrl()+"/exchanges?countryId="+countryId, HttpMethod.GET, null, new ParameterizedTypeReference<Response<List<Exchange>>>() {}));
	}

}
